package main

import (
	"errors"
	"fmt"
)

func  exception_test(){
	defer func() {
		err :=  recover()
		if err != nil{
			fmt.Println("err= ", err)
		}
	}()
	num1 := 10
	num2 :=  0
	res :=  num1 / num2
	fmt.Println(res)
}

func exception_test1(name string) error{
	if name == "haha"{
		return nil
	}else {
		//自定义错误
		return errors.New("这是一个自定义错误")
	}
}

func main() {
	exception_test()

	error := exception_test1("aaa")
	if error != nil {
		panic(error)
	}
	fmt.Println("asdasfd")
}